package com.resjz.milddog.Implement.role;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.resjz.milddog.Interface.role.RoleInterface;
import com.resjz.milddog.Interface.user.UserInterface;
import com.resjz.milddog.entity.menu.RoleMenuEntity;
import com.resjz.milddog.entity.role.UserRoleEntity;
import com.resjz.milddog.entity.user.UserEntity;
import com.resjz.milddog.service.menu.RoleMenuService;
import com.resjz.milddog.service.role.UserRoleService;
import com.resjz.milddog.service.user.userService;
import com.resjz.milddog.vo.Role.UserRoleVo;
import com.resjz.milddog.vo.user.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Method;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@org.apache.dubbo.config.annotation.DubboService(version = "${dubbo.service.version}",retries = 2)
@Slf4j
public class RoleInterfaceImpl implements RoleInterface {
    @Autowired
    private UserRoleService userRoleService;
    @Override
    public List<UserRoleVo> getUserRoles(Long userId) {
        List<UserRoleVo> backlist = new ArrayList<>();
        List<UserRoleEntity> list = userRoleService.list(new QueryWrapper<UserRoleEntity>().eq("user_id",userId));
        list.stream().forEach(ori->{
            UserRoleVo userRoleVo = new UserRoleVo();
            userRoleVo.setUserId(userId);
            userRoleVo.setRoleId(ori.getRoleId());
            backlist.add(userRoleVo);
        });
        return backlist;
    }
}
